package com.pig4cloud.common.seate.properties;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.boot.context.properties.ConfigurationProperties;

@Data
@Accessors(chain = true)
@NoArgsConstructor
@ConfigurationProperties("spring.seate.config")
public class SeateRegisterConfigProperties {
        /**
         * type : file
         * nacos : {"serverAddr":"localhost","namespace":"","group":"SEATA_GROUP","username":"","password":""}
         * consul : {"serverAddr":"127.0.0.1:8500"}
         * apollo : {"appId":"seata-server","apolloMeta":"http://192.168.1.204:8801","namespace":"application"}
         * zk : {"serverAddr":"127.0.0.1:2181","sessionTimeout":6000,"connectTimeout":2000,"username":"","password":""}
         * etcd3 : {"serverAddr":"http://localhost:2379"}
         * file : {"name":"file.conf"}
         */

        private String type = "file";
        private NacosPropertiesX nacos = new NacosPropertiesX();
        private ConsulPropertiesX consul = new ConsulPropertiesX();
        private ApolloProperties apollo = new ApolloProperties();
        private ZkPropertiesX zk = new ZkPropertiesX();
        private Etcd3PropertiesX etcd3 = new Etcd3PropertiesX();
        private FilePropertiesX file = new FilePropertiesX();

        @Data
        @Accessors(chain = true)
        @NoArgsConstructor
        public static class NacosPropertiesX {
            /**
             * serverAddr : localhost
             * namespace :
             * group : SEATA_GROUP
             * username :
             * password :
             */

            private String serverAddr = "localhost";
            private String namespace = "";
            private String group = "SEATA_GROUP";
            private String username = "";
            private String password = "";
        }

        @Data
        @Accessors(chain = true)
        @NoArgsConstructor
        public static class ConsulPropertiesX {
            /**
             * serverAddr : 127.0.0.1:8500
             */

            private String serverAddr = "127.0.0.1:8500";
        }

        @Data
        @Accessors(chain = true)
        @NoArgsConstructor
        public static class ApolloProperties {
            /**
             * appId : seata-server
             * apolloMeta : http://192.168.1.204:8801
             * namespace : application
             */

            private String appId = "seata-server";
            private String apolloMeta = "http://192.168.1.204:8801";
            private String namespace = "application";
        }

        @Data
        @Accessors(chain = true)
        @NoArgsConstructor
        public static class ZkPropertiesX {
            /**
             * serverAddr : 127.0.0.1:2181
             * sessionTimeout : 6000
             * connectTimeout : 2000
             * username :
             * password :
             */

            private String serverAddr = "127.0.0.1:2181";
            private int sessionTimeout = 6000;
            private int connectTimeout = 2000;
            private String username = "";
            private String password = "";
        }

        @Data
        @Accessors(chain = true)
        @NoArgsConstructor
        public static class Etcd3PropertiesX {
            /**
             * serverAddr : http://localhost:2379
             */

            private String serverAddr = "http://localhost:2379";
        }

        @Data
        @Accessors(chain = true)
        @NoArgsConstructor
        public static class FilePropertiesX {
            /**
             * name : file.conf
             */

            private String name = "file.conf";
        }
    
}
